#!/usr/bin/env python
# encoding: utf-8
# Date: 2017-07-31
# file:views.py
# Email: wang521kang@outlook.com
# Author: 王康
from record.models import Commodity, Property, Value, Type
from utils.views import get_json


def create_goods(request, name, price, preferential, category_id, com_property, value):
    commodity = Commodity()
    commodity.name = name
    commodity.price = price
    commodity.preferential = preferential
    commodity.type = category_id
    commodity.save()
    return get_json()


def create_category(request, commodity_category):
    category = Type()
    category.type = commodity_category
    return get_json(True, '创建分类成功')


def create_property(request, com_property, commodity_id):
    properties = Property()
    properties.property = com_property
    properties.commodity = commodity_id
    properties.save()
    return get_json(True, '创建规格名成功')


def create_value(request, properties_id, value):
    values = Value()
    values.property = properties_id
    values.value = value
    values.save()
    return get_json(True, '创建规格成功')


def create_record(request):
    return get_json()
